{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5d8069ec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "range(1, 11)\n"
     ]
    }
   ],
   "source": [
    "# 1~10\n",
    "i = range(1,11)\n",
    "\n",
    "print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "58f8892f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n"
     ]
    }
   ],
   "source": [
    "# 1~10的平方\n",
    "i = [x*x for x in range(1,11)]\n",
    "\n",
    "print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "14c9eeb4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[4, 16, 36, 64, 100]\n"
     ]
    }
   ],
   "source": [
    "# 1~10的平方中的偶数\n",
    "i = [x*x for x in range(1,11) if(x%2 == 0 )]\n",
    "\n",
    "print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9b566ee3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a=1', 'b=2', 'c=3', 'd=4']\n"
     ]
    }
   ],
   "source": [
    "map = {'a':1, 'b':2, 'c':3, 'd':4}\n",
    "\n",
    "list = [i + '=' + str(v) for i,v in map.items()]\n",
    "\n",
    "print(list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "605db795",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "True\n",
      "True\n",
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "from collections.abc import Iterable\n",
    "\n",
    "print(isinstance([1,2,3] , Iterable))\n",
    "\n",
    "print(isinstance((1,2,3) , Iterable))\n",
    "\n",
    "print(isinstance({1:1,2:2,3:3} ,Iterable))\n",
    "\n",
    "print(isinstance({1,2,3} ,Iterable))\n",
    "\n",
    "print(isinstance(123 ,Iterable))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "8f2be574",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "False\n",
      "False\n",
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "from collections.abc import Iterator\n",
    "\n",
    "print(isinstance([1,2,3] , Iterator))\n",
    "\n",
    "print(isinstance((1,2,3) , Iterator))\n",
    "\n",
    "print(isinstance({1:1,2:2,3:3} ,Iterator))\n",
    "\n",
    "print(isinstance({1,2,3} ,Iterator))\n",
    "\n",
    "print(isinstance((x for x in range(0,11)) ,Iterator))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
